Exclude the Liquibase lock table and drop a no-op psql flag - #14
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two independent fixes to
setup-postgres-preview-schema/job-template.yml, both found while migrating the test applications to clustertest02.1.
--set=SESSION_REPLICATION_ROLE=replicanever did anything--setdefines a psql client variable, not a server parameter. The intent was clearly to disable triggers during the load, and that never happened.Measured against a live PostgreSQL 18 database:
The server keeps
origin. The value exists only as a client variable that nothing reads.Why the fix is removal, not a real
SETThe obvious repair would be the SQL
SET session_replication_role = replica;. That cannot work here, because this job connects as the application role:With
--set=ON_ERROR_STOP=1that error would abort every preview build. Granting the application role superuser to clone a schema is not worth it.Why removing it is safe
A plain-format
pg_dumpwrites the data first and adds the foreign keys at the end, so no trigger has to be suppressed during theCOPYphase. In a real dump of one of our schemas:Roughly eleven thousand lines of data land before the first foreign key exists. The flag protected nothing, and its absence changes nothing.
2. The Liquibase lock row is cloned into every preview
databasechangeloglockholds runtime state, not history. Copying its row means a preview inherits whatever lock the base schema happened to hold. A base schema captured while Liquibase was mid-run hands the preview a lock that is already taken, and the preview application then blocks on startup.--exclude-table-datakeeps the table and drops its rows, so Liquibase writes a fresh lock row on first start. Verified against a live database:databasechangelogkeeps its rows on purpose. That is the migration history, and the preview needs it so Liquibase applies no changeset twice.Testing
Both commands were run against a live PostgreSQL 18 instance, on a real application schema. The job template still parses as a valid Kubernetes
Job.One thing this pull request does not fix
The
sedthat renames the base schema rewrites every occurrence of"${BASE_SCHEMA}", including references to objects that merely live in that schema. We hit this on Aichner:pg_trgmhad been created without an explicit schema, so it landed in the application schema, andpg_dumpemitted the trigram indexes as"main"."gin_trgm_ops". The rename turned that into"preview_1003"."gin_trgm_ops", which does not exist, and six preview jobs failed with:A purely textual rename cannot distinguish the two cases, so the durable fix belongs in the applications: never create an extension inside the application schema. Aichner now recreates
pg_trgminpublic. It may be worth stating that in the action's readme, so the next project does not repeat it.🤖 Generated with Claude Code